package mail.fetch.netease;

import mail.util.FileManager;

import java.net.CookieManager;
import java.nio.charset.Charset;
import java.util.List;

/**
 * @author: Hanjiafeng
 * @date: Created in 17:32 2019/2/28
 * @desc: 网易邮箱入口
 */
public class NetEaseEntrance {

    //todo 2019年3月12日10:42:03 处理下异常抛出

    @SuppressWarnings("t2")
    private static void t2() throws Exception {
        MailType mailType = MailType.MAIL_163;

        Login11 login11 = new Login11(null);
        CookieManager cookieManager;
        switch (mailType) {
            case MAIL_163:
                cookieManager = login11.getCookieManager(mailType, "tianlangqiqingh@163.com", "huifenghechang");
                break;
            case MAIL_126:
                cookieManager = login11.getCookieManager(mailType, "hulushuju@126.com", "daihoubang");
                break;
            case MAIL_YEAH:
                cookieManager = login11.getCookieManager(mailType, "hulushuju@yeah.net", "daihoubang");
                break;
            default:
                return;
        }
        Inbox11 inbox11 = new Inbox11(cookieManager, null);
        List<NetEasyMailEntity> netEasyMailEntityList = inbox11.getMailListDuringHalfYear(mailType);
        for (NetEasyMailEntity entity : netEasyMailEntityList) {
            FileManager.overwrite("F:\\NetEasyCreditBill\\" + System.currentTimeMillis() + ".html", entity.getContent()
                    , Charset.forName("gb2312"));
        }
    }

    public static void main(String... args) throws Exception {

        String proxyIp1 = "localhost";
        String proxyPort1 = "8888";

        System.setProperty("http.proxyHost", proxyIp1);
        System.setProperty("https.proxyHost", proxyIp1);
        System.setProperty("http.proxyPort", proxyPort1);
        System.setProperty("https.proxyPort", proxyPort1);

        t2();
    }
}
